<?php
include 'index.php';
?>

<div id="body-wrapper">
    <div id="main-content">
        <div class="content-box">

            <?php
            include '../db/db_con.php';
            ?>

            <?php
            if (isset($_POST['addadvertise'])) {
                if ($_FILES["image"]["name"] != "") {


        if ($_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/jpeg" || $_FILES["image"]["type"] == "image/jpg" || $_FILES["image"]["type"] == "image/pjpeg") {

            move_uploaded_file($_FILES["image"]["tmp_name"], "img/upload/" . $_FILES["image"]["name"]);

            $img = "img/upload/" . $_FILES["image"]["name"];
        }else{
            echo 'no '.mysql_error();
        }
    }
                $width = $_POST['width'];
                $height = $_POST['height'];
                $url = $_POST['url'];

                $query = "INSERT INTO advertisements (img,width,height,url)VALUES ('{$img}',{$width},{$height},'{$url}')";

                if (mysql_query($query)) {

                    echo '
<div class="notification success png_bg">
<a href="" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
<div>
	This Advertise Added Is Done ..
</div>
</div>';

                } else {

                    echo '
<div class="notification error png_bg">
<a href="" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
<div>
	This Advertise Added Is Not Done ..
</div>
</div>';
                }
            }

            ?>

            <div class="content-box-header" id = "addProducts" >

                <h3><?= Add_Advertise ?></h3>

                <div class="clear"></div>

            </div>

            <div class="content-box-content">
                <div class="tab-content default-tab" id="tab2">

                    <form action="AddAdvers.php?type=Advertise&lang=<?= $lang ?>" method="post" name = "addadvertise" enctype="multipart/form-data">

                        <fieldset>

                            <p>
                                <label><?= Advertise_width ?> </label>
                                <input class="text-input small-input" type="text" id="small-input" name="width" />
                            </p>

                            <p>
                                <label><?= Advertise_height ?></label>
                                <input class="text-input small-input" type="text" id="small-input" name="height" />
                            </p>

                            <p>
                                <label><?= Advertise_URL ?></label>
                                <input class="text-input small-input" type="text" id="small-input" name="url" />
                            </p>

                            <p>
                                <label><?= Advertise_Image ?></label>
                                <input type="file" name="image" class="small-input"/>
                            </p>

                            <p>
                                <input class="button" type="submit" name = "addadvertise" value="<?= Add_Advertise ?>" />
                            </p>

                        </fieldset>

                        <div class="clear"></div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>